# Load Necessary Packages
library(estimatr)
library(ggplot2)

# Load Datasets
setwd("/users/josephphillips/Dropbox/COVID-19/Data/FC Data Repository")
usa <- read.csv("USA.csv",header=T,sep=",")
uk <- read.csv("UK.csv",header=T,sep=",")
canada <- read.csv("Canada 1.csv",header=T,sep=",")
canada2 <- read.csv("Canada 2.csv",header=T,sep=",")

# Figure 1
us_plot_reg1.tfc <- lm_robust(target_false~W2only+W3only+both+college+frequent_church+pid3+ideo7+lives_highincidence+crt+knowledge+nonwhite+health_trust+media_trust,data=usa)
us_plot_reg2.tfc <- lm_robust(W2_target_false~W2only+W3only+both+ideo7+health_trust+media_trust+target_false,data=usa)
us_plot_reg3.tfc <- lm_robust(W3_target_false~W2only+W3only+both+pid3+ideo7+health_trust+media_trust+target_false,data=usa)
us_plot_reg4.tfc <- lm_robust(W4_target_false~W2only+W3only+both+pid3+ideo7+crt+health_trust+media_trust+target_false,data=usa)
uk_plot_reg1.tfc <- lm_robust(targeted_false~W2only+W3only+both+university+age35+left+ideology1+knowledge+nonwhite+polinterest+trust_healthgov+total_media_trust,data=uk)
uk_plot_reg2.tfc <- lm_robust(W2_targeted_false~W2only+W3only+both+ideology1+knowledge+trust_healthgov+targeted_false,data=uk)
uk_plot_reg3.tfc <- lm_robust(W3_targeted_false~W2only+W3only+both+ideology1+knowledge+trust_healthgov+targeted_false,data=uk)
ca1_plot_reg_tfc <- lm_robust(targeted_false~treat+university+age55+age65+male+frequentchurch+west+right+ideology1+knowledge+nonwhite+polinterest+trust_healthgov+total_media_trust,data=canada)
ca2_plot_reg_tfc <- lm_robust(targeted_false~treat+age45+age55+age65+male+frequentchurch+left+right+ideology1+knowledge+nonwhite+polinterest+trust_healthgov,data=canada2)

W2only_plot_data <- subset(data.frame(wave=c(1,2,3,4,1,2,3,2,2),
                                country=factor(c("USA","USA","USA","USA","GB","GB","GB","CA1","CA2"),levels=c("USA","GB","CA1","CA2")),
tfc=c(us_plot_reg1.tfc$coefficients[2],us_plot_reg2.tfc$coefficients[2],us_plot_reg3.tfc$coefficients[2],us_plot_reg4.tfc$coefficients[2],uk_plot_reg1.tfc$coefficients[2],uk_plot_reg2.tfc$coefficients[2],uk_plot_reg3.tfc$coefficients[2],ca1_plot_reg_tfc$coefficients[2],ca2_plot_reg_tfc$coefficients[2]),
tfc_lci=c(us_plot_reg1.tfc$conf.low[2],us_plot_reg2.tfc$conf.low[2],us_plot_reg3.tfc$conf.low[2],us_plot_reg4.tfc$conf.low[2],uk_plot_reg1.tfc$conf.low[2],uk_plot_reg2.tfc$conf.low[2],uk_plot_reg3.tfc$conf.low[2],ca1_plot_reg_tfc$conf.low[2],ca2_plot_reg_tfc$conf.low[2]),
tfc_uci=c(us_plot_reg1.tfc$conf.high[2],us_plot_reg2.tfc$conf.high[2],us_plot_reg3.tfc$conf.high[2],us_plot_reg4.tfc$conf.high[2],uk_plot_reg1.tfc$conf.high[2],uk_plot_reg2.tfc$conf.high[2],uk_plot_reg3.tfc$conf.high[2],ca1_plot_reg_tfc$conf.high[2],ca2_plot_reg_tfc$conf.high[2])),country=="USA" | country=="GB")

canada_plot_data <- subset(data.frame(wave=c(1,2,3,4,1,2,3,2,2),
                               country=factor(c("USA","USA","USA","USA","GB","GB","GB","CA1","CA2"),levels=c("USA","GB","CA1","CA2")),
tfc=c(us_plot_reg1.tfc$coefficients[2],us_plot_reg2.tfc$coefficients[2],us_plot_reg3.tfc$coefficients[2],us_plot_reg4.tfc$coefficients[2],uk_plot_reg1.tfc$coefficients[2],uk_plot_reg2.tfc$coefficients[2],uk_plot_reg3.tfc$coefficients[2],ca1_plot_reg_tfc$coefficients[2],ca2_plot_reg_tfc$coefficients[2]),
tfc_lci=c(us_plot_reg1.tfc$conf.low[2],us_plot_reg2.tfc$conf.low[2],us_plot_reg3.tfc$conf.low[2],us_plot_reg4.tfc$conf.low[2],uk_plot_reg1.tfc$conf.low[2],uk_plot_reg2.tfc$conf.low[2],uk_plot_reg3.tfc$conf.low[2],ca1_plot_reg_tfc$conf.low[2],ca2_plot_reg_tfc$conf.low[2]),
tfc_uci=c(us_plot_reg1.tfc$conf.high[2],us_plot_reg2.tfc$conf.high[2],us_plot_reg3.tfc$conf.high[2],us_plot_reg4.tfc$conf.high[2],uk_plot_reg1.tfc$conf.high[2],uk_plot_reg2.tfc$conf.high[2],uk_plot_reg3.tfc$conf.high[2],ca1_plot_reg_tfc$conf.high[2],ca2_plot_reg_tfc$conf.high[2])),country=="CA1" | country=="CA2")

W3only_plot_data <- subset(data.frame(wave=c(1,2,3,4,1,2,3,2,2),
                               country=factor(c("USA","USA","USA","USA","GB","GB","GB","CA1","CA2"),levels=c("USA","GB","CA1","CA2")),
tfc=c(us_plot_reg1.tfc$coefficients[3],us_plot_reg2.tfc$coefficients[3],us_plot_reg3.tfc$coefficients[3],us_plot_reg4.tfc$coefficients[3],uk_plot_reg1.tfc$coefficients[3],uk_plot_reg2.tfc$coefficients[3],uk_plot_reg3.tfc$coefficients[3],ca1_plot_reg_tfc$coefficients[3],ca2_plot_reg_tfc$coefficients[3]),
tfc_lci=c(us_plot_reg1.tfc$conf.low[3],us_plot_reg2.tfc$conf.low[3],us_plot_reg3.tfc$conf.low[3],us_plot_reg4.tfc$conf.low[3],uk_plot_reg1.tfc$conf.low[3],uk_plot_reg2.tfc$conf.low[3],uk_plot_reg3.tfc$conf.low[3],ca1_plot_reg_tfc$conf.low[3],ca2_plot_reg_tfc$conf.low[3]),
tfc_uci=c(us_plot_reg1.tfc$conf.high[3],us_plot_reg2.tfc$conf.high[3],us_plot_reg3.tfc$conf.high[3],us_plot_reg4.tfc$conf.high[3],uk_plot_reg1.tfc$conf.high[3],uk_plot_reg2.tfc$conf.high[3],uk_plot_reg3.tfc$conf.high[3],ca1_plot_reg_tfc$conf.high[3],ca2_plot_reg_tfc$conf.high[3])),country=="USA" | country=="GB")

both_plot_data <- subset(data.frame(wave=c(1,2,3,4,1,2,3,2,2),
                                     country=factor(c("USA","USA","USA","USA","GB","GB","GB","CA1","CA2"),levels=c("USA","GB","CA1","CA2")),
tfc=c(us_plot_reg1.tfc$coefficients[4],us_plot_reg2.tfc$coefficients[4],us_plot_reg3.tfc$coefficients[4],us_plot_reg4.tfc$coefficients[4],uk_plot_reg1.tfc$coefficients[4],uk_plot_reg2.tfc$coefficients[4],uk_plot_reg3.tfc$coefficients[4],ca1_plot_reg_tfc$coefficients[4],ca2_plot_reg_tfc$coefficients[4]),
tfc_lci=c(us_plot_reg1.tfc$conf.low[4],us_plot_reg2.tfc$conf.low[4],us_plot_reg3.tfc$conf.low[4],us_plot_reg4.tfc$conf.low[4],uk_plot_reg1.tfc$conf.low[4],uk_plot_reg2.tfc$conf.low[4],uk_plot_reg3.tfc$conf.low[4],ca1_plot_reg_tfc$conf.low[4],ca2_plot_reg_tfc$conf.low[4]),
tfc_uci=c(us_plot_reg1.tfc$conf.high[4],us_plot_reg2.tfc$conf.high[4],us_plot_reg3.tfc$conf.high[4],us_plot_reg4.tfc$conf.high[4],uk_plot_reg1.tfc$conf.high[4],uk_plot_reg2.tfc$conf.high[4],uk_plot_reg3.tfc$conf.high[4],ca1_plot_reg_tfc$conf.high[4],ca2_plot_reg_tfc$conf.high[4])),country=="USA" | country=="GB")

cbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")

plot_w2only_tfc <- ggplot(W2only_plot_data,aes(x=wave,y=tfc,group=country,color=country)) + geom_point(position=position_dodge(0.2)) + 
scale_color_manual(name="Country",limits=c("USA","GB","CA1","CA2"),labels=c("USA","GB","Canada 1","Canada 2"),values=cbPalette) + geom_line(linetype="dashed",position=position_dodge(0.2)) + geom_errorbar(aes(ymin=tfc_lci,ymax=tfc_uci),size=.4,width=0,position=position_dodge(0.2)) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="gray40") + scale_x_continuous(name="Wave",breaks=c(1,2,3,4),labels=c("Pre","Treat","Post","Post")) + ylab("Difference from control") + ggtitle("W2 factcheck only") + theme(plot.title = element_text(hjust = 0.5)) + ylim(-0.48,0.28)
plot_w3only_tfc <- ggplot(W3only_plot_data,aes(x=wave,y=tfc,group=country,color=country)) + geom_point(position=position_dodge(0.2)) + scale_color_manual(name="Country",limits=c("USA","GB"),values=cbPalette) + geom_line(linetype="dashed",position=position_dodge(0.2)) + geom_errorbar(aes(ymin=tfc_lci,ymax=tfc_uci),size=.4,width=0,position=position_dodge(0.2)) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="gray40") + scale_x_continuous(name="Wave",breaks=c(1,2,3,4),labels=c("Pre","Pre","Treat","Post")) + ylab("") + ggtitle("W3 factcheck only") + theme(plot.title = element_text(hjust = 0.5)) + ylim(-0.48,0.28)
plot_both_tfc <- ggplot(both_plot_data,aes(x=wave,y=tfc,group=country,color=country)) + geom_point(position=position_dodge(0.2)) + scale_color_manual(name="Country",limits=c("USA","GB"),values=cbPalette) + geom_line(linetype="dashed",position=position_dodge(0.2)) + geom_errorbar(aes(ymin=tfc_lci,ymax=tfc_uci),size=.4,width=0,position=position_dodge(0.2)) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="gray40") + scale_x_continuous(name="Wave",breaks=c(1,2,3,4),labels=c("Pre","Treat1","Treat2","Post")) + ylab("") + ggtitle("W2/W3 factchecks") + theme(plot.title = element_text(hjust = 0.5)) + ylim(-0.48,0.28)
plot_canada_tfc <- ggplot(canada_plot_data,aes(x=wave,y=tfc,group=country,color=country)) + geom_point(position=position_dodge(0.2)) + scale_color_manual(name="Country",limits=c("CA1","CA2"),labels=c("Canada 1","Canada 2"),values=c("#56B4E9","#009E73")) + geom_line(linetype="dashed",position=position_dodge(0.2)) + geom_errorbar(aes(ymin=tfc_lci,ymax=tfc_uci),size=.4,width=0,position=position_dodge(0.2)) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="gray40") + scale_x_continuous(name="Wave",limits=c(1,4),breaks=c(1,2,3,4),labels=c("N/A","Treat","N/A","N/A")) + ylab("") + ggtitle("Single-wave factchecks") + theme(plot.title = element_text(hjust = 0.5)) + ylim(-0.48,0.28)

p.tfc <- ggarrange(plot_w2only_tfc,plot_w3only_tfc,plot_both_tfc,plot_canada_tfc,nrow=1,common.legend=T,legend="bottom")

# Figure 2
us_plot_reg1.tfc.loapp <- lm_robust(target_false~W2only+W3only+both+college+frequent_church+pid3+ideo7+lives_highincidence+crt+knowledge+nonwhite+health_trust+media_trust,data=usa,subset=approve_trmp<2)
us_plot_reg2.tfc.loapp <- lm_robust(W2_target_false~W2only+W3only+both+ideo7+health_trust+media_trust+target_false,data=usa,subset=approve_trmp<2)
us_plot_reg3.tfc.loapp <- lm_robust(W3_target_false~W2only+W3only+both+pid3+ideo7+health_trust+media_trust+target_false,data=usa,subset=approve_trmp<2)
us_plot_reg4.tfc.loapp <- lm_robust(W4_target_false~W2only+W3only+both+pid3+ideo7+crt+health_trust+media_trust+target_false,data=usa,subset=approve_trmp<2)
us_plot_reg1.tfc.hiapp <- lm_robust(target_false~W2only+W3only+both+college+frequent_church+pid3+ideo7+lives_highincidence+crt+knowledge+nonwhite+health_trust+media_trust,data=usa,subset=approve_trmp>=2)
us_plot_reg2.tfc.hiapp <- lm_robust(W2_target_false~W2only+W3only+both+ideo7+health_trust+media_trust+target_false,data=usa,subset=approve_trmp>=2)
us_plot_reg3.tfc.hiapp <- lm_robust(W3_target_false~W2only+W3only+both+pid3+ideo7+health_trust+media_trust+target_false,data=usa,subset=approve_trmp>=2)
us_plot_reg4.tfc.hiapp <- lm_robust(W4_target_false~W2only+W3only+both+pid3+ideo7+crt+health_trust+media_trust+target_false,data=usa,subset=approve_trmp>=2)
uk_plot_reg1.tfc.loapp <- lm_robust(targeted_false~W2only+W3only+both+university+age35+left+ideology1+knowledge+nonwhite+polinterest+trust_healthgov+total_media_trust,data=uk,subset=approve_Boris<2)
uk_plot_reg2.tfc.loapp <- lm_robust(W2_targeted_false~W2only+W3only+both+ideology1+knowledge+trust_healthgov+targeted_false,data=uk,subset=approve_Boris<2)
uk_plot_reg3.tfc.loapp <- lm_robust(W3_targeted_false~W2only+W3only+both+ideology1+knowledge+trust_healthgov+targeted_false,data=uk,subset=approve_Boris<2)
uk_plot_reg1.tfc.hiapp <- lm_robust(targeted_false~W2only+W3only+both+university+age35+left+ideology1+knowledge+nonwhite+polinterest+trust_healthgov+total_media_trust,data=uk,subset=approve_Boris>=2)
uk_plot_reg2.tfc.hiapp <- lm_robust(W2_targeted_false~W2only+W3only+both+ideology1+knowledge+trust_healthgov+targeted_false,data=uk,subset=approve_Boris>=2)
uk_plot_reg3.tfc.hiapp <- lm_robust(W3_targeted_false~W2only+W3only+both+ideology1+knowledge+trust_healthgov+targeted_false,data=uk,subset=approve_Boris>=2)
ca1_plot_reg_tfc.loapp <- lm_robust(targeted_false~treat+university+age55+age65+male+frequentchurch+west+right+ideology1+knowledge+nonwhite+polinterest+trust_healthgov+total_media_trust,data=canada,subset=approve_trudeau<2)
ca1_plot_reg_tfc.hiapp <- lm_robust(targeted_false~treat+university+age55+age65+male+frequentchurch+west+right+ideology1+knowledge+nonwhite+polinterest+trust_healthgov+total_media_trust,data=canada,subset=approve_trudeau>=2)
ca2_plot_reg_tfc.loapp <- lm_robust(targeted_false~treat+age45+age55+age65+male+frequentchurch+left+right+ideology1+knowledge+nonwhite+polinterest+trust_healthgov,data=canada2,subset=approve_trudeau<2)
ca2_plot_reg_tfc.hiapp <- lm_robust(targeted_false~treat+age45+age55+age65+male+frequentchurch+left+right+ideology1+knowledge+nonwhite+polinterest+trust_healthgov,data=canada2,subset=approve_trudeau>=2)

W2only_leader <- subset(data.frame(wave=c(1,2,3,4,1,2,3,1,1,1,2,3,4,1,2,3,2,2),
                                   approval=c("Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval"),
                                   country=factor(c("USA","USA","USA","USA","GB","GB","GB","CA1","CA2","USA","USA","USA","USA","GB","GB","GB","CA1","CA2"),levels=c("USA","GB","CA1","CA2")),
                                   tfc=c(us_plot_reg1.tfc.loapp$coefficients[2],us_plot_reg2.tfc.loapp$coefficients[2],us_plot_reg3.tfc.loapp$coefficients[2],us_plot_reg4.tfc.loapp$coefficients[2],uk_plot_reg1.tfc.loapp$coefficients[2],uk_plot_reg2.tfc.loapp$coefficients[2],uk_plot_reg3.tfc.loapp$coefficients[2],ca1_plot_reg_tfc.loapp$coefficients[2],ca2_plot_reg_tfc.loapp$coefficients[2],us_plot_reg1.tfc.hiapp$coefficients[2],us_plot_reg2.tfc.hiapp$coefficients[2],us_plot_reg3.tfc.hiapp$coefficients[2],us_plot_reg4.tfc.hiapp$coefficients[2],uk_plot_reg1.tfc.hiapp$coefficients[2],uk_plot_reg2.tfc.hiapp$coefficients[2],uk_plot_reg3.tfc.hiapp$coefficients[2],ca1_plot_reg_tfc.hiapp$coefficients[2],ca2_plot_reg_tfc.hiapp$coefficients[2]),
                                   tfc_lci=c(us_plot_reg1.tfc.loapp$conf.low[2],us_plot_reg2.tfc.loapp$conf.low[2],us_plot_reg3.tfc.loapp$conf.low[2],us_plot_reg4.tfc.loapp$conf.low[2],uk_plot_reg1.tfc.loapp$conf.low[2],uk_plot_reg2.tfc.loapp$conf.low[2],uk_plot_reg3.tfc.loapp$conf.low[2],ca1_plot_reg_tfc.loapp$conf.low[2],ca2_plot_reg_tfc.loapp$conf.low[2],us_plot_reg1.tfc.hiapp$conf.low[2],us_plot_reg2.tfc.hiapp$conf.low[2],us_plot_reg3.tfc.hiapp$conf.low[2],us_plot_reg4.tfc.hiapp$conf.low[2],uk_plot_reg1.tfc.hiapp$conf.low[2],uk_plot_reg2.tfc.hiapp$conf.low[2],uk_plot_reg3.tfc.hiapp$conf.low[2],ca1_plot_reg_tfc.hiapp$conf.low[2],ca2_plot_reg_tfc.hiapp$conf.low[2]),
                                   tfc_uci=c(us_plot_reg1.tfc.loapp$conf.high[2],us_plot_reg2.tfc.loapp$conf.high[2],us_plot_reg3.tfc.loapp$conf.high[2],us_plot_reg4.tfc.loapp$conf.high[2],uk_plot_reg1.tfc.loapp$conf.high[2],uk_plot_reg2.tfc.loapp$conf.high[2],uk_plot_reg3.tfc.loapp$conf.high[2],ca1_plot_reg_tfc.loapp$conf.high[2],ca2_plot_reg_tfc.loapp$conf.high[2],us_plot_reg1.tfc.hiapp$conf.high[2],us_plot_reg2.tfc.hiapp$conf.high[2],us_plot_reg3.tfc.hiapp$conf.high[2],us_plot_reg4.tfc.hiapp$conf.high[2],uk_plot_reg1.tfc.hiapp$conf.high[2],uk_plot_reg2.tfc.hiapp$conf.high[2],uk_plot_reg3.tfc.hiapp$conf.high[2],ca1_plot_reg_tfc.hiapp$conf.high[2],ca2_plot_reg_tfc.hiapp$conf.high[2])),country=="USA" | country=="GB")

Canada_leader <- subset(data.frame(wave=c(1,2,3,4,1,2,3,2,2,1,2,3,4,1,2,3,2,2),
                                   approval=c("Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval"),
                                   country=factor(c("USA","USA","USA","USA","GB","GB","GB","CA1","CA2","USA","USA","USA","USA","GB","GB","GB","CA1","CA2"),levels=c("USA","GB","CA1","CA2")),
                                   tfc=c(us_plot_reg1.tfc.loapp$coefficients[2],us_plot_reg2.tfc.loapp$coefficients[2],us_plot_reg3.tfc.loapp$coefficients[2],us_plot_reg4.tfc.loapp$coefficients[2],uk_plot_reg1.tfc.loapp$coefficients[2],uk_plot_reg2.tfc.loapp$coefficients[2],uk_plot_reg3.tfc.loapp$coefficients[2],ca1_plot_reg_tfc.loapp$coefficients[2],ca2_plot_reg_tfc.loapp$coefficients[2],us_plot_reg1.tfc.hiapp$coefficients[2],us_plot_reg2.tfc.hiapp$coefficients[2],us_plot_reg3.tfc.hiapp$coefficients[2],us_plot_reg4.tfc.hiapp$coefficients[2],uk_plot_reg1.tfc.hiapp$coefficients[2],uk_plot_reg2.tfc.hiapp$coefficients[2],uk_plot_reg3.tfc.hiapp$coefficients[2],ca1_plot_reg_tfc.hiapp$coefficients[2],ca2_plot_reg_tfc.hiapp$coefficients[2]),
                                   tfc_lci=c(us_plot_reg1.tfc.loapp$conf.low[2],us_plot_reg2.tfc.loapp$conf.low[2],us_plot_reg3.tfc.loapp$conf.low[2],us_plot_reg4.tfc.loapp$conf.low[2],uk_plot_reg1.tfc.loapp$conf.low[2],uk_plot_reg2.tfc.loapp$conf.low[2],uk_plot_reg3.tfc.loapp$conf.low[2],ca1_plot_reg_tfc.loapp$conf.low[2],ca2_plot_reg_tfc.loapp$conf.low[2],us_plot_reg1.tfc.hiapp$conf.low[2],us_plot_reg2.tfc.hiapp$conf.low[2],us_plot_reg3.tfc.hiapp$conf.low[2],us_plot_reg4.tfc.hiapp$conf.low[2],uk_plot_reg1.tfc.hiapp$conf.low[2],uk_plot_reg2.tfc.hiapp$conf.low[2],uk_plot_reg3.tfc.hiapp$conf.low[2],ca1_plot_reg_tfc.hiapp$conf.low[2],ca2_plot_reg_tfc.hiapp$conf.low[2]),
                                   tfc_uci=c(us_plot_reg1.tfc.loapp$conf.high[2],us_plot_reg2.tfc.loapp$conf.high[2],us_plot_reg3.tfc.loapp$conf.high[2],us_plot_reg4.tfc.loapp$conf.high[2],uk_plot_reg1.tfc.loapp$conf.high[2],uk_plot_reg2.tfc.loapp$conf.high[2],uk_plot_reg3.tfc.loapp$conf.high[2],ca1_plot_reg_tfc.loapp$conf.high[2],ca2_plot_reg_tfc.loapp$conf.high[2],us_plot_reg1.tfc.hiapp$conf.high[2],us_plot_reg2.tfc.hiapp$conf.high[2],us_plot_reg3.tfc.hiapp$conf.high[2],us_plot_reg4.tfc.hiapp$conf.high[2],uk_plot_reg1.tfc.hiapp$conf.high[2],uk_plot_reg2.tfc.hiapp$conf.high[2],uk_plot_reg3.tfc.hiapp$conf.high[2],ca1_plot_reg_tfc.hiapp$conf.high[2],ca2_plot_reg_tfc.hiapp$conf.high[2])),country=="CA1" | country=="CA2")
Canada_leader$country <- ifelse(Canada_leader$country=="CA1","Canada 1","Canada 2")

W3only_leader <- subset(data.frame(wave=c(1,2,3,4,1,2,3,1,1,1,2,3,4,1,2,3,2,2),
                                   approval=c("Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval"),
                                   country=factor(c("USA","USA","USA","USA","GB","GB","GB","CA1","CA2","USA","USA","USA","USA","GB","GB","GB","CA1","CA2"),levels=c("USA","GB","CA1","CA2")),
                                   tfc=c(us_plot_reg1.tfc.loapp$coefficients[3],us_plot_reg2.tfc.loapp$coefficients[3],us_plot_reg3.tfc.loapp$coefficients[3],us_plot_reg4.tfc.loapp$coefficients[3],uk_plot_reg1.tfc.loapp$coefficients[3],uk_plot_reg2.tfc.loapp$coefficients[3],uk_plot_reg3.tfc.loapp$coefficients[3],ca1_plot_reg_tfc$coefficients[3],ca2_plot_reg_tfc$coefficients[3],us_plot_reg1.tfc.hiapp$coefficients[3],us_plot_reg2.tfc.hiapp$coefficients[3],us_plot_reg3.tfc.hiapp$coefficients[3],us_plot_reg4.tfc.hiapp$coefficients[3],uk_plot_reg1.tfc.hiapp$coefficients[3],uk_plot_reg2.tfc.hiapp$coefficients[3],uk_plot_reg3.tfc.hiapp$coefficients[3],ca1_plot_reg_tfc$coefficients[3],ca2_plot_reg_tfc$coefficients[3]),
                                   tfc_lci=c(us_plot_reg1.tfc.loapp$conf.low[3],us_plot_reg2.tfc.loapp$conf.low[3],us_plot_reg3.tfc.loapp$conf.low[3],us_plot_reg4.tfc.loapp$conf.low[3],uk_plot_reg1.tfc.loapp$conf.low[3],uk_plot_reg2.tfc.loapp$conf.low[3],uk_plot_reg3.tfc.loapp$conf.low[3],ca1_plot_reg_tfc$conf.low[3],ca2_plot_reg_tfc$conf.low[3],us_plot_reg1.tfc.hiapp$conf.low[3],us_plot_reg2.tfc.hiapp$conf.low[3],us_plot_reg3.tfc.hiapp$conf.low[3],us_plot_reg4.tfc.hiapp$conf.low[3],uk_plot_reg1.tfc.hiapp$conf.low[3],uk_plot_reg2.tfc.hiapp$conf.low[3],uk_plot_reg3.tfc.hiapp$conf.low[3],ca1_plot_reg_tfc$conf.low[3],ca2_plot_reg_tfc$conf.low[3]),
                                   tfc_uci=c(us_plot_reg1.tfc.loapp$conf.high[3],us_plot_reg2.tfc.loapp$conf.high[3],us_plot_reg3.tfc.loapp$conf.high[3],us_plot_reg4.tfc.loapp$conf.high[3],uk_plot_reg1.tfc.loapp$conf.high[3],uk_plot_reg2.tfc.loapp$conf.high[3],uk_plot_reg3.tfc.loapp$conf.high[3],ca1_plot_reg_tfc$conf.high[3],ca2_plot_reg_tfc$conf.high[3],us_plot_reg1.tfc.hiapp$conf.high[3],us_plot_reg2.tfc.hiapp$conf.high[3],us_plot_reg3.tfc.hiapp$conf.high[3],us_plot_reg4.tfc.hiapp$conf.high[3],uk_plot_reg1.tfc.hiapp$conf.high[3],uk_plot_reg2.tfc.hiapp$conf.high[3],uk_plot_reg3.tfc.hiapp$conf.high[3],ca1_plot_reg_tfc$conf.high[3],ca2_plot_reg_tfc$conf.high[3])),country=="USA" | country=="GB")

both_leader <- subset(data.frame(wave=c(1,2,3,4,1,2,3,1,1,1,2,3,4,1,2,3,2,2),
                                 approval=c("Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","Low Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval","High Approval"),
                                 country=factor(c("USA","USA","USA","USA","GB","GB","GB","CA1","CA2","USA","USA","USA","USA","GB","GB","GB","CA1","CA2"),levels=c("USA","GB","CA1","CA2")),
                                    tfc=c(us_plot_reg1.tfc.loapp$coefficients[4],us_plot_reg2.tfc.loapp$coefficients[4],us_plot_reg3.tfc.loapp$coefficients[4],us_plot_reg4.tfc.loapp$coefficients[4],uk_plot_reg1.tfc.loapp$coefficients[4],uk_plot_reg2.tfc.loapp$coefficients[4],uk_plot_reg3.tfc.loapp$coefficients[4],ca1_plot_reg_tfc$coefficients[4],ca2_plot_reg_tfc$coefficients[4],us_plot_reg1.tfc.hiapp$coefficients[4],us_plot_reg2.tfc.hiapp$coefficients[4],us_plot_reg3.tfc.hiapp$coefficients[4],us_plot_reg4.tfc.hiapp$coefficients[4],uk_plot_reg1.tfc.hiapp$coefficients[4],uk_plot_reg2.tfc.hiapp$coefficients[4],uk_plot_reg3.tfc.hiapp$coefficients[4],ca1_plot_reg_tfc$coefficients[4],ca2_plot_reg_tfc$coefficients[4]),
                                    tfc_lci=c(us_plot_reg1.tfc.loapp$conf.low[4],us_plot_reg2.tfc.loapp$conf.low[4],us_plot_reg3.tfc.loapp$conf.low[4],us_plot_reg4.tfc.loapp$conf.low[4],uk_plot_reg1.tfc.loapp$conf.low[4],uk_plot_reg2.tfc.loapp$conf.low[4],uk_plot_reg3.tfc.loapp$conf.low[4],ca1_plot_reg_tfc$conf.low[4],ca2_plot_reg_tfc$conf.low[4],us_plot_reg1.tfc.hiapp$conf.low[4],us_plot_reg2.tfc.hiapp$conf.low[4],us_plot_reg3.tfc.hiapp$conf.low[4],us_plot_reg4.tfc.hiapp$conf.low[4],uk_plot_reg1.tfc.hiapp$conf.low[4],uk_plot_reg2.tfc.hiapp$conf.low[4],uk_plot_reg3.tfc.hiapp$conf.low[4],ca1_plot_reg_tfc$conf.low[4],ca2_plot_reg_tfc$conf.low[4]),
                                    tfc_uci=c(us_plot_reg1.tfc.loapp$conf.high[4],us_plot_reg2.tfc.loapp$conf.high[4],us_plot_reg3.tfc.loapp$conf.high[4],us_plot_reg4.tfc.loapp$conf.high[4],uk_plot_reg1.tfc.loapp$conf.high[4],uk_plot_reg2.tfc.loapp$conf.high[4],uk_plot_reg3.tfc.loapp$conf.high[4],ca1_plot_reg_tfc$conf.high[4],ca2_plot_reg_tfc$conf.high[4],us_plot_reg1.tfc.hiapp$conf.high[4],us_plot_reg2.tfc.hiapp$conf.high[4],us_plot_reg3.tfc.hiapp$conf.high[4],us_plot_reg4.tfc.hiapp$conf.high[4],uk_plot_reg1.tfc.hiapp$conf.high[4],uk_plot_reg2.tfc.hiapp$conf.high[4],uk_plot_reg3.tfc.hiapp$conf.high[4],ca1_plot_reg_tfc$conf.high[4],ca2_plot_reg_tfc$conf.high[4])),country=="USA" | country=="GB")

plot_w2only_leader <- ggplot(W2only_leader,aes(x=wave,y=tfc,color=approval,group=approval)) + geom_point(position=position_dodge(0.2)) + scale_color_manual(name="Approval",limits=c("High Approval","Low Approval"),labels=c("High","Low"),values=cbPalette) + geom_line(linetype="dashed",position=position_dodge(0.2)) + geom_errorbar(aes(ymin=tfc_lci,ymax=tfc_uci),size=.4,width=0,position=position_dodge(0.2)) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="gray40") + scale_x_continuous(name="Wave",breaks=c(1,2,3,4),labels=c("Pre","Treat","Post","Post")) + ylab("Difference from control") + ggtitle("W2 factcheck only") + theme(plot.title = element_text(hjust = 0.5)) + ylim(-0.48,0.28) + facet_grid(country~.)
plot_w3only_leader <- ggplot(W3only_leader,aes(x=wave,y=tfc,group=approval,color=approval)) + geom_point(position=position_dodge(0.2)) + scale_color_manual(name="Approval",limits=c("High Approval","Low Approval"),labels=c("High","Low"),values=cbPalette) + geom_line(linetype="dashed",position=position_dodge(0.2)) + geom_errorbar(aes(ymin=tfc_lci,ymax=tfc_uci),size=.4,width=0,position=position_dodge(0.2)) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="gray40") + scale_x_continuous(name="Wave",breaks=c(1,2,3,4),labels=c("Pre","Pre","Treat","Post")) + ylab("") + ggtitle("W3 factcheck only") + theme(plot.title = element_text(hjust = 0.5)) + ylim(-0.48,0.28) + facet_grid(country~.)
plot_both_leader <- ggplot(both_leader,aes(x=wave,y=tfc,group=approval,color=approval)) + geom_point(position=position_dodge(0.2)) + scale_color_manual(name="Approval",limits=c("High Approval","Low Approval"),labels=c("High","Low"),values=cbPalette) + geom_line(linetype="dashed",position=position_dodge(0.2)) + geom_errorbar(aes(ymin=tfc_lci,ymax=tfc_uci),size=.4,width=0,position=position_dodge(0.2)) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="gray40") + scale_x_continuous(name="Wave",breaks=c(1,2,3,4),labels=c("Pre","Treat1","Treat2","Post")) + ylab("") + ggtitle("W2/W3 factchecks") + theme(plot.title = element_text(hjust = 0.5)) + ylim(-0.48,0.28) + facet_grid(country~.)
plot_canada_leader <- ggplot(Canada_leader,aes(x=wave,y=tfc,group=approval,color=approval)) + geom_point(position=position_dodge(0.2)) + scale_color_manual(name="Approval",limits=c("High Approval","Low Approval"),labels=c("High","Low"),values=cbPalette) + geom_line(linetype="dashed",position=position_dodge(0.2)) + geom_errorbar(aes(ymin=tfc_lci,ymax=tfc_uci),size=.4,width=0,position=position_dodge(0.2)) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="gray40") + scale_x_continuous(name="Wave",limits=c(1,4),breaks=c(1,2,3,4),labels=c("N/A","Treat","N/A","N/A")) + ylab("") + ggtitle("Single-wave factchecks") + theme(plot.title = element_text(hjust = 0.5)) + ylim(-0.48,0.28) + facet_grid(country~.)

p.leader <- ggarrange(plot_w2only_leader,plot_w3only_leader,plot_both_leader,plot_canada_leader,nrow=2,ncol=2,common.legend=T,legend="bottom")